/*eslint spaced-comment:0*/
/*eslint import/prefer-default-export:0*/
export const dateFormat = function (ts) {
  const d = new Date(ts)
  const yyyy = `0000${d.getFullYear()}`.slice(-4)
  const MM = `00${d.getMonth() + 1}`.slice(-2)
  const dd = `00${d.getDate()}`.slice(-2)
  const HH = `00${d.getHours()}`.slice(-2)
  const mm = `00${d.getMinutes()}`.slice(-2)
  const ss = `00${d.getSeconds()}`.slice(-2)
  return `${yyyy}-${MM}-${dd} ${HH}:${mm}:${ss}`
}

export function getNowTime() {
  const now = new Date()
  const year = now.getFullYear() //得到年份
  const month = now.getMonth() + 1 //得到月份
  const date = now.getDate() //得到日期
  const hour = now.getHours() //得到小时数
  const minute = now.getMinutes() //得到分钟数
  const second = now.getSeconds() //得到秒数
  const nowDateTime = year + '-' + month + '-' + date + ' ' + hour + ':' + minute + ':' + second
  return nowDateTime
}

export function os() {
  var ua = navigator.userAgent,
    isWindowsPhone = /(?:Windows Phone)/.test(ua),
    isSymbian = /(?:SymbianOS)/.test(ua) || isWindowsPhone,
    isAndroid = /(?:Android)/.test(ua),
    isFireFox = /(?:Firefox)/.test(ua),
    isChrome = /(?:Chrome|CriOS)/.test(ua),
    isTablet = /(?:iPad|PlayBook)/.test(ua) || (isAndroid && !/(?:Mobile)/.test(ua)) || (isFireFox && /(?:Tablet)/.test(ua)),
    isPhone = /(?:iPhone)/.test(ua) && !isTablet,
    isPc = !isPhone && !isAndroid && !isSymbian;
  return {
    isTablet: isTablet,
    isPhone: isPhone,
    isAndroid: isAndroid,
    isPc: isPc
  };
};
// if (os.isAndroid || os.isPhone) {
//   // 手机

// } else if (os.isTablet) {
//   // 平板

// } else if (os.isPc) {
//   // pc

// }